<template>
  <div class="smart-recommend-interface">
    <!-- 返回按钮 -->
    <div class="back-section">
      <button class="back-btn" @click="goBack">
        <span class="back-icon">←</span>
        返回学习
      </button>
    </div>

    <!-- 智能推荐模式头部 -->
    <div class="quick-mode-header">
      <div class="glass-card quick-header-card">
        <div class="quick-header-content">
          <div class="quick-header-icon">🎯</div>
          <div class="quick-header-info">
            <h2 class="quick-header-title">智能推荐学习</h2>
            <p class="quick-header-subtitle">{{ selectedCategory?.name }} > {{ selectedSubCategory?.name }}</p>
            <p class="quick-header-desc">根据你的答题情况，系统会智能推荐下一道题目</p>
          </div>
        </div>
      </div>
    </div>

    <!-- 加载中 -->
    <div v-if="loading" class="loading-section">
      <div class="glass-card completion-card">
        <div class="completion-header">
          <div class="completion-icon">⏳</div>
          <h2 class="completion-title">正在为你获取题目</h2>
          <p class="completion-subtitle">请稍候...</p>
        </div>
      </div>
    </div>

    <!-- 题目卡片 -->
    <div v-else-if="!isFinished && q" class="question-section">
      <div class="glass-card question-card">
        <div class="question-header">
          <div class="question-type-badge" :class="getQuestionTypeClass(q.type)">
            {{ getQuestionTypeText(q.type) }}
          </div>
        </div>

        <div class="question-content">
          <h3 class="question-concept">{{ q.concept }}</h3>
          <p class="question-text">{{ q.title }}</p>

          <!-- 模式切换按钮：编写答案 / 查看答案 / 下一题 -->
          <div class="mode-buttons">
            <button class="mode-btn" @click="startWrite">📝 编写答案</button>
            <button class="mode-btn" @click="viewAnswer">👀 查看答案</button>
            <button class="mode-btn primary" @click="nextQuestion">➡️ 下一题</button>
          </div>

          <!-- 选择题 -->
          <div v-if="uiMode === 'write' && (q.type === 'single_choice' || q.type === 'multiple_choice')" class="options-container">
            <div
              v-for="(option, index) in q.options"
              :key="option"
              class="option-item"
              :class="{ selected: answer === option, disabled: showFeedback }"
              @click="!showFeedback && selectOption(option)"
            >
              <div class="option-marker">{{ String.fromCharCode(65 + index) }}</div>
              <div class="option-content">{{ option }}</div>
              <div class="option-icon" v-if="showFeedback">
                <span v-if="option === q.answer" class="correct-icon">✅</span>
                <span v-else-if="option === answer && answer !== q.answer" class="incorrect-icon">❌</span>
              </div>
            </div>
          </div>

          <!-- 判断题 -->
          <div v-if="uiMode === 'write' && q.type === 'boolean'" class="boolean-container">
            <div
              v-for="option in booleanOptions"
              :key="option.value"
              class="boolean-option"
              :class="{ selected: answer === option.value, disabled: showFeedback }"
              @click="!showFeedback && selectOption(option.value)"
            >
              <div class="boolean-icon">{{ option.icon }}</div>
              <div class="boolean-text">{{ option.label }}</div>
              <div class="option-icon" v-if="showFeedback">
                <span v-if="String(option.value) === String(q.answer)" class="correct-icon">✅</span>
                <span v-else-if="String(option.value) === String(answer) && String(answer) !== String(q.answer)" class="incorrect-icon">❌</span>
              </div>
            </div>
          </div>

          <!-- 填空题 -->
          <div v-if="uiMode === 'write' && q.type === 'fill'" class="fill-container">
            <div class="input-wrapper">
              <input
                v-model="answer"
                type="text"
                class="fill-input"
                placeholder="请输入答案"
                :disabled="showFeedback"
              />
            </div>
          </div>

          <!-- 代码题 -->
          <div v-if="uiMode === 'write' && q.type === 'code'" class="code-container">
            <div class="code-editor">
              <textarea
                v-model="answer"
                class="code-textarea"
                placeholder="请输入代码"
                :disabled="showFeedback"
                rows="6"
              ></textarea>
            </div>
          </div>

          <!-- 简答题 -->
          <div v-if="uiMode === 'write' && q.questionTypeCode === 'short_answer'" class="short-answer-container">
            <div class="answer-area">
              <div class="answer-header">
                <span class="answer-label">📝 请在此处输入您的答案：</span>
                <span class="word-count">{{ answer.length }}/500</span>
              </div>
              <textarea
                v-model="answer"
                class="answer-textarea"
                placeholder="请详细描述您的答案，建议包含关键概念、步骤说明或相关示例..."
                :disabled="showFeedback"
                rows="8"
                maxlength="500"
              ></textarea>
            </div>
          </div>
        </div>

        <!-- 提交按钮：仅在编写答案模式显示 -->
        <div class="action-buttons" v-if="uiMode === 'write'">
          <button
            class="submit-btn"
            :class="{ disabled: !answer || !answer.trim() }"
            :disabled="!answer || !answer.trim()"
            @click="submit"
          >
            <span class="btn-icon">📝</span>
            {{ q.type === 'short_answer' ? '提交简答' : '提交答案' }}
          </button>
        </div>

        <!-- 查看答案模式下，仅展示正确答案 -->
        <div v-if="uiMode === 'view'" class="feedback-section">
          <div class="feedback-content">
            <div class="correct-answer">
              <span class="label">正确答案：</span>
              <span class="answer">{{ q.answer }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 空/完成状态 -->
    <div v-else>
      <!-- 已有作答记录则显示完成页面 -->
      <div v-if="recommendTotalQuestions > 0" class="completion-section">
        <div class="glass-card completion-card">
          <div class="completion-header">
            <div class="completion-icon">🎯</div>
            <h2 class="completion-title">本次学习结束</h2>
            <p class="completion-subtitle">你可以继续学习或查看学习报告</p>
          </div>

          <div class="quick-completion-stats">
            <div class="quick-stat-card">
              <div class="quick-stat-icon">✅</div>
              <div class="quick-stat-content">
                <div class="quick-stat-value">{{ correctAnswers }}</div>
                <div class="quick-stat-label">答对题目</div>
              </div>
            </div>
            <div class="quick-stat-card">
              <div class="quick-stat-icon">📈</div>
              <div class="quick-stat-content">
                <div class="quick-stat-value">{{ accuracyRate }}%</div>
                <div class="quick-stat-label">正确率</div>
              </div>
            </div>
          </div>

          <div class="completion-actions">
            <button class="primary-btn" @click="continueLearning">
              <span class="btn-icon">🚀</span>
              继续学习
            </button>
            <button class="secondary-btn" @click="goBack">
              <span class="btn-icon">↩️</span>
              返回学习
            </button>
          </div>
        </div>
      </div>

      <!-- 无题目数据的空态页面 -->
      <div v-else class="empty-section">
        <div class="glass-card completion-card">
          <div class="completion-header">
            <div class="completion-icon">📭</div>
            <h2 class="completion-title">暂无题目数据</h2>
            <p class="completion-subtitle">请稍后重试，或更换分类后再试</p>
          </div>
          <div class="completion-actions">
            <button class="primary-btn" @click="continueLearning">
              <span class="btn-icon">🔄</span>
              重新获取题目
            </button>
            <button class="secondary-btn" @click="goBack">
              <span class="btn-icon">↩️</span>
              返回学习
            </button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>


<script>
import { getRecommandQuestion, submitAnswerAndGetNext } from '@/api/question'

export default {
  name: "SmartRecommendInterface",
  data() {
    return {
      answer: "",
      uiMode: "none", // none | write | view
      showFeedback: false,
      correct: false,
      booleanOptions: [
        { value: "true", label: "正确", icon: "✅" },
        { value: "false", label: "错误", icon: "❌" },
      ],
      loading: false,
      recommendSessionId: null,
      selectedCategory: null,
      selectedSubCategory: null,
    }
  },
  computed: {
    q() {
      return this.$store.state.currentRecommendQuestion;
    },
    isFinished() {
      return !this.$store.state.currentRecommendQuestion;
    },
    correctAnswers() {
      return this.$store.state.recommendAnswers.filter(answer => answer.correct).length;
    },
    recommendTotalQuestions() {
      return this.$store.state.recommendAnswers.length;
    },
    accuracyRate() {
      return this.recommendTotalQuestions > 0 
        ? Math.round((this.correctAnswers / this.recommendTotalQuestions) * 100)
        : 0;
    }
  },
  methods: {
    startWrite() {
      this.uiMode = "write";
    },
    viewAnswer() {
      this.uiMode = "view";
    },
    selectOption(option) {
      this.answer = option;
    },

    getQuestionTypeClass(type) {
      const classes = {
        all: "type-all",
        single_choice: "type-choice",
        multiple_choice: "type-choice",
        boolean: "type-boolean",
        fill: "type-fill",
        code: "type-code",
        sort: "type-sort",
        match: "type-match",
        short_answer: "type-short-answer",
        case: "type-case",
      };
      return classes[type] || "type-default";
    },

    getQuestionTypeText(type) {
      const texts = {
        all: "全部题型",
        single_choice: "单选题",
        multiple_choice: "多选题",
        boolean: "判断题",
        fill: "填空题",
        code: "编程题",
        sort: "排序题",
        match: "匹配题",
        short_answer: "简答题",
        case: "案例题",
      };
      return texts[type] || "题目";
    },

    async submit() {
      if (!this.q) return;
      
      // 判断正确性
      if (this.q.type === "code") {
        this.correct = this.answer.includes(this.q.answer);
      } else if (this.q.type === "boolean") {
        this.correct = String(this.answer) === String(this.q.answer);
      } else if (this.q.type === "single_choice" || this.q.type === "multiple_choice") {
        this.correct = this.answer === this.q.answer;
      } else if (this.q.type === "fill") {
        this.correct = this.answer === this.q.answer;
      } else if (this.q.type === "short_answer" || this.q.type === "case") {
        this.correct = this.evaluateShortAnswer(this.answer, this.q.answer);
      } else {
        this.correct = this.answer === this.q.answer;
      }
      
      this.showFeedback = true;
      await this.submitQuickAnswer();
    },

    async nextQuestion() {
      await this.getRecommandQuestion();
      this.uiMode = "none";
    },

    async submitQuickAnswer() {
      try {
        this.loading = true;
        
        const answerData = {
          sessionId: this.$store.state.recommendSessionId,
          questionId: this.q.id,
          answer: this.answer,
          correct: this.correct,
          categoryId: this.selectedSubCategory?.id,
          subCategoryId: this.selectedSubCategory?.id
        };
        
        const response = await submitAnswerAndGetNext(answerData);
        
        if (response) {
          this.$store.commit('addRecommendAnswer', {
            questionId: this.q.id,
            question: this.q.title || this.q.question,
            answer: this.answer,
            correct: this.correct,
            explanation: this.q.explanation
          });
          
          if (response.nextQuestion) {
            this.$store.commit('setCurrentRecommendQuestion', response.nextQuestion);
            this.answer = "";
            this.showFeedback = false;
            this.correct = false;
          } else {
            // 没有下一题，显示完成页面
            this.$store.commit('setCurrentRecommendQuestion', null);
          }
        }
      } catch (error) {
        console.error('提交答案失败:', error);
        this.$message.error('提交答案失败，请稍后重试');
      } finally {
        this.loading = false;
      }
    },

    async getRecommandQuestion() {
      try {
        this.loading = true;
        
        const params = {
          sessionId: this.$store.state.recommendSessionId,
          categoryId: this.selectedSubCategory?.id
        };
        const response = await getRecommandQuestion(params);
        console.log(response)
        if (response && response.code === 200 && response.data) {
          const q = response.data || {};
          const normalized = {
            ...q,
            // 兼容现有前端逻辑所需的字段
            type: q.questionTypeCode || q.type,
            options: Array.isArray(q.options) ? q.options : (q.options ? q.options : []),
          };
          this.$store.commit('setCurrentRecommendQuestion', normalized);
          this.answer = "";
          this.showFeedback = false;
          this.correct = false;
        } else {
          // 未获取到题目，直接进入空/完成状态
          this.$store.commit('setCurrentRecommendQuestion', null);
        }
      } catch (error) {
        console.error('获取下一题失败:', error);
        this.$message.error('获取下一题失败，请稍后重试');
      } finally {
        this.loading = false;
      }
    },

    evaluateShortAnswer(userAnswer, correctAnswer) {
      if (!userAnswer || !correctAnswer) return false;
      
      const user = userAnswer.toLowerCase().trim();
      const correct = correctAnswer.toLowerCase().trim();
      
      if (user === correct) return true;
      
      const keywords = correct.split(/[，,。.！!？?；;]/).filter(word => word.trim().length > 1);
      const matchedKeywords = keywords.filter(keyword => user.includes(keyword.trim()));
      
      if (keywords.length > 0 && matchedKeywords.length / keywords.length >= 0.6) {
        return true;
      }
      
      if (user.length < 10) return false;
      
      const userWords = user.split(/\s+/);
      const correctWords = correct.split(/\s+/);
      const commonWords = userWords.filter(word => correctWords.includes(word));
      
      if (commonWords.length >= Math.min(userWords.length, correctWords.length) * 0.4) {
        return true;
      }
      
      return false;
    },

    

    async continueLearning() {
      await this.getRecommandQuestion();
    },

    goBack() {
      this.$router.push('/learn');
    },

    async initRecommendMode() {
      try {
        this.loading = true;
        
        // 从路由参数获取分类信息
        // 这里应该根据ID获取分类信息，暂时使用模拟数据
        this.selectedCategory = { 
          id: this.$route.query.categoryId, 
          name: this.$route.query.categoryName 
        };
        this.selectedSubCategory = { 
          id: this.$route.query.subCategoryId, 
          name: this.$route.query.subCategoryName 
        };
        
        const sessionId = 'recommend_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
        this.recommendSessionId = sessionId;
        
        this.$store.commit('setSmartRecommendMode', { 
          enabled: true, 
          sessionId: sessionId 
        });
        
        await this.getRecommandQuestion();
      } catch (error) {
        console.error('初始化智能推荐模式失败:', error);
        this.$message.error('初始化失败，请稍后重试');
      } finally {
        this.loading = false;
      }
    }
  },

  async mounted() {
    await this.initRecommendMode();
  }
};
</script>

<style scoped>
/* 智能推荐界面样式 */
.smart-recommend-interface {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

/* 返回按钮 */
.back-section {
  margin-bottom: 20px;
}

.back-btn {
  background-color: #4a90e2;
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.3s ease;
}

.back-btn:hover {
  background-color: #357abd;
}

.back-icon {
  font-size: 20px;
}

/* 智能推荐模式头部 */
.quick-mode-header {
  margin-bottom: 30px;
}

.quick-header-card {
  display: flex;
  align-items: center;
  padding: 25px 30px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 20px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.quick-header-content {
  display: flex;
  align-items: center;
  gap: 15px;
}

.quick-header-icon {
  font-size: 2.5rem;
  color: #3b82f6;
}

.quick-header-info {
  text-align: left;
}

.quick-header-title {
  font-size: 1.5rem;
  color: #2c3e50;
  margin: 0 0 5px 0;
  font-weight: 600;
}

.quick-header-subtitle {
  font-size: 0.9rem;
  color: #7f8c8d;
  margin: 0 0 10px 0;
}

.quick-header-desc {
  font-size: 0.8rem;
  color: #856404;
  line-height: 1.4;
}

/* 卡片基础样式 */
.glass-card {
  background: white;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  margin-bottom: 20px;
}

/* 题目区域 */
.question-section {
  position: relative;
  z-index: 1;
}

.question-card {
  margin: 0 auto;
  animation: slideInUp 0.6s ease-out;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

.question-type-badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
}

.type-choice {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
}

.type-boolean {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.type-fill {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.type-code {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.type-short-answer {
  background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
}

.question-content {
  margin-bottom: 30px;
}

.question-concept {
  font-size: 1.3rem;
  color: #2c3e50;
  margin: 0 0 15px 0;
  font-weight: 600;
}

.question-text {
  font-size: 1.1rem;
  color: #34495e;
  line-height: 1.6;
  margin: 0 0 25px 0;
}

/* 选项样式 */
.options-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-item {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.option-item:hover:not(.disabled) {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.05);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.option-item.selected {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

.option-item.disabled {
  cursor: not-allowed;
  opacity: 0.8;
}

.option-marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  margin-right: 15px;
  flex-shrink: 0;
}

.option-content {
  flex: 1;
  font-size: 1rem;
  color: #2c3e50;
  line-height: 1.4;
}

.option-icon {
  margin-left: 10px;
}

.correct-icon {
  font-size: 1.2rem;
}

.incorrect-icon {
  font-size: 1.2rem;
}

/* 判断题样式 */
.boolean-container {
  display: flex;
  gap: 20px;
}

.boolean-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.boolean-option:hover:not(.disabled) {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.05);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.boolean-option.selected {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

.boolean-icon {
  font-size: 2rem;
  margin-bottom: 10px;
}

.boolean-text {
  font-size: 1rem;
  color: #2c3e50;
  font-weight: 500;
}

/* 填空题样式 */
.fill-container {
  margin-top: 20px;
}

.input-wrapper {
  position: relative;
}

.fill-input {
  width: 100%;
  padding: 15px 20px;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  font-size: 1rem;
  color: #2c3e50;
  background: white;
  transition: all 0.3s ease;
}

.fill-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  transform: translateY(-1px);
}

.fill-input:disabled {
  background: #f8f9fa;
  cursor: not-allowed;
}

/* 代码题样式 */
.code-container {
  margin-top: 20px;
}

.code-editor {
  border: 2px solid #e9ecef;
  border-radius: 12px;
  overflow: hidden;
  background: #f8f9fa;
}

.code-textarea {
  width: 100%;
  padding: 20px;
  border: none;
  background: transparent;
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #2c3e50;
  resize: vertical;
}

.code-textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.code-textarea:disabled {
  cursor: not-allowed;
}

/* 简答题样式 */
.short-answer-container {
  margin-top: 20px;
}

.answer-area {
  border: 2px solid #e9ecef;
  border-radius: 12px;
  background: white;
  overflow: hidden;
  transition: all 0.3s ease;
}

.answer-area:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  transform: translateY(-1px);
}

.answer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-bottom: 1px solid #e9ecef;
}

.answer-label {
  font-size: 0.95rem;
  color: #2c3e50;
  font-weight: 500;
}

.word-count {
  font-size: 0.8rem;
  color: #7f8c8d;
  font-weight: 500;
  padding: 4px 8px;
  background: white;
  border-radius: 12px;
  border: 1px solid #e9ecef;
}

.answer-textarea {
  width: 100%;
  padding: 20px;
  border: none;
  background: transparent;
  font-family: "Inter", "Segoe UI", "Roboto", sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: #2c3e50;
  resize: vertical;
  min-height: 200px;
}

.answer-textarea:focus {
  outline: none;
}

.answer-textarea:disabled {
  cursor: not-allowed;
  background: #f8f9fa;
}

.answer-textarea::placeholder {
  color: #bdc3c7;
  font-style: italic;
}

 

/* 按钮样式 */
.action-buttons {
  text-align: center;
}

 

/* 模式切换按钮样式 */
.mode-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 20px;
  justify-content: center;
}

.mode-btn {
  padding: 10px 18px;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  color: #2c3e50;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
}

.mode-btn.primary {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
  color: #fff;
  border: none;
}

.mode-btn.primary:hover {
  box-shadow: 0 8px 20px rgba(30, 58, 138, 0.25);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.submit-btn {
  padding: 15px 40px;
  border: none;
  border-radius: 25px;
  font-size: 1.1rem;
  font-weight: 600;
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.submit-btn:hover:not(.disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(30, 58, 138, 0.4);
}

.submit-btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-icon {
  font-size: 1.1rem;
}

/* 反馈区域 */
.feedback-section {
  margin-top: 30px;
  padding: 25px;
  border-radius: 15px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid rgba(0, 0, 0, 0.05);
  animation: slideInDown 0.5s ease-out;
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feedback-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
}

.feedback-header.correct {
  color: #27ae60;
}

.feedback-header.incorrect {
  color: #e74c3c;
}

.feedback-icon {
  font-size: 2rem;
}

.feedback-title {
  font-size: 1.3rem;
  font-weight: 600;
}

.feedback-content {
  margin-bottom: 25px;
}

.correct-answer {
  margin-bottom: 15px;
  padding: 12px 16px;
  background: rgba(231, 76, 60, 0.1);
  border-radius: 8px;
  border-left: 4px solid #e74c3c;
}

.label {
  font-weight: 600;
  color: #2c3e50;
}

.answer {
  color: #e74c3c;
  font-weight: 500;
}

.explanation {
  padding: 12px 16px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 8px;
  border-left: 4px solid #3b82f6;
}

.text {
  color: #2c3e50;
  line-height: 1.5;
}

.feedback-actions {
  text-align: center;
}

.next-btn {
  padding: 12px 30px;
  border: none;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.next-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(30, 58, 138, 0.3);
}

/* 完成页面 */
.completion-section {
  position: relative;
  z-index: 1;
}

.completion-card {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
  animation: zoomIn 0.8s ease-out;
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.completion-header {
  margin-bottom: 30px;
}

.completion-icon {
  font-size: 4rem;
  margin-bottom: 15px;
}

.completion-title {
  font-size: 2rem;
  color: #2c3e50;
  margin: 0 0 10px 0;
  font-weight: 700;
}

.completion-subtitle {
  font-size: 1.1rem;
  color: #7f8c8d;
  margin: 0;
}

.quick-completion-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}

.quick-stat-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 15px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.quick-stat-icon {
  font-size: 1.5rem;
}

.quick-stat-content {
  text-align: left;
}

.quick-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #3b82f6;
}

.quick-stat-label {
  font-size: 0.8rem;
  color: #7f8c8d;
}

.completion-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn {
  padding: 15px 30px;
  border: none;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.primary-btn {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
  color: white;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(30, 58, 138, 0.3);
}

.secondary-btn {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  color: #2c3e50;
  border: 2px solid #e9ecef;
}

.secondary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .quick-header-content {
    flex-direction: column;
    text-align: center;
  }
  
  .boolean-container {
    flex-direction: column;
  }
  
  .quick-completion-stats {
    grid-template-columns: 1fr;
  }
  
  .completion-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .primary-btn,
  .secondary-btn {
    width: 100%;
    max-width: 300px;
    justify-content: center;
  }
  
  .answer-header {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
  
  .answer-textarea {
    min-height: 150px;
    padding: 15px;
  }
}

@media (max-width: 480px) {
  .option-item {
    padding: 12px 15px;
  }
  
  .option-marker {
    width: 25px;
    height: 25px;
    font-size: 0.8rem;
  }
  
  .submit-btn {
    padding: 12px 30px;
    font-size: 1rem;
  }
  
  .next-btn {
    padding: 10px 25px;
    font-size: 0.9rem;
  }
  
  .primary-btn,
  .secondary-btn {
    padding: 12px 25px;
    font-size: 0.9rem;
  }
  
  .answer-textarea {
    min-height: 120px;
    padding: 12px;
    font-size: 0.9rem;
  }
  
  .answer-header {
    padding: 12px 15px;
  }
  
  
}
</style>
